<?php
    require_once('../code/global.php');
    require_once('/code/Admin.php');
    require_once('/code/News.php');
    $admin=new Admin();
    $admin->loginCheck(1);
    $news=new News();
    $n=$news->getNews(0);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>PhotoFromThe1st 后台管理系统</title>
        <link rel="stylesheet" href="/styles/admin.css" type="text/css" media="all">
        <script type="text/javascript" src="/script/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="/script/script.js"></script>
        <script type="text/javascript">
            window.parent.scroll(0,0);
        </script>
    </head>
    <body>
        <?php
            if(isset($_GET['msg'])) echo '<div class="msgBox">'.$_GET['msg'].'</div>';
            else echo '<div class="msgBox">新闻管理</div>';
                
        ?>
        <table border="0" cellspacing="0" cellpadding="0" class="detailTable">
            <tr class="header"><td>News Caption</td><td>Active</td><td>Actions</td></tr>
            <form name="addNews" action="exec.php" method="post"><input type="hidden" name="action" value="addNews"><tr><td><input type="text" name="caption" maxlength="128" class="captionBox"></td><td class="align-center"><input name="is_active" type="checkbox" checked></td><td class="btnTd"><input class="btnLnk" type="submit" name="add" value="Add"></td></tr></form>
            <tr><td class="seperator" colspan="3"></td></tr>
        <?php
            $n_count=count($n);
            $i=0;
            while($i<$n_count){
                $nid=$n[$i]['news_id'];
                echo '<form name="deleteNews'.$nid.'" action="exec.php" method="post"><tr><td>'.$n[$i]['caption'].'</td><td class="align-center"><input type="checkbox" disabled '.($n[$i]['is_active']?'checked':'').'></td><td class="btnTd"><input class="btnLnk" type="button" value="Edit" onclick="location.href=\'editNews.php?nid='.$nid.'\'"><input type="hidden" name="action" value="deleteNews"><input type="hidden" name="news_id" value="'.$nid.'"><input class="btnLnk btnDel" type="submit" value="Delete"></td></tr></form>';
                ++$i;
            }
        ?>
    </table>
    </body>
</html>